import request from '@/utils/request';

const API = {
    // 公共教室预约记录 (管理员)
    PUBLICCLASS_Manager_NOTE_URL: '/public/classroom/manager/select',
    // 公共教室预约记录 代办和已办
    PUBLICCLASS_Manager_NOTE_PROCCESSED_URL:
        '/public/classroom/manager/getIsNeed',
    // 公共教师预约记录
    PUBLICCLASS_NOTE_URL: '/public/classroom/info/applicationlist?isApprove=1',
    // 获取公共教室预约选项
    PUBLICCLASS_OPTION_URL: '/public/classroom/subscribe/listClassroom',
    // 获取公共教室预约所需的时间
    PUBLICCLASS_TIME_OPTION_URL: '/public/classroom/subscribe/getTimeByName',
    // 老师获取公共教室预约
    PUBLICCLASS_NOTE_TEACHER_URL: '/public/classroom/info/listSubscribeInfo',
    // 预约公共教室预约
    ADD_PUBLICCLASS_NOTE_URL: '/public/classroom/subscribe/add',
    // 获取公共教室详情
    GET_PUBLICCLASS_DETAIL_URL: '/public/classroom/info/getOne',
    // 删除公共教室详情
    DELETE_PUBLICCLASS_NOTE_URL: '/public/classroom/subscribe/remove',
    // 审批公共教室预约
    EXAMINE_PUBLICCLASS_NOTE_URL: '/public/classroom/info/approve'
};

// 公共教室预约记录 (管理员)
export const reqPublicClassManagerNote = (pageNo, pageSize = 5) =>
    request.post(API.PUBLICCLASS_Manager_NOTE_URL, { pageNo, pageSize });

// 公共教室预约申请待办和已办
export const reqPublicClassNoteProccessed = (
    pageNo,
    pageSize = 5,
    managerStatus
) =>
    request.post(API.PUBLICCLASS_Manager_NOTE_PROCCESSED_URL, {
        pageNo,
        pageSize,
        managerStatus
    });

export const reqPublicClassNote = (pageNo, pageSize = 5) =>
    request.get(
        `${API.PUBLICCLASS_NOTE_URL}&pageNo=${pageNo}&pageSize=${pageSize}`
    );

// 查询公共教室预约
export const reqInquirePublicClassNote = data =>
    request.post(API.PUBLICCLASS_Manager_NOTE_URL, data);

// 获取公共教室预约选项
export const reqPublicClassOption = () =>
    request.get(API.PUBLICCLASS_OPTION_URL);

// 获取公共教室所预约的时间选项
export const reqPublicClassTimeOption = (name, data) =>
    request.get(`${API.PUBLICCLASS_TIME_OPTION_URL}?name=${name}&date=${data}`);

// 老师获取公共教室预约
export const reqPublicClassInTeacher = (pageNo, pageSize) =>
    request.post(API.PUBLICCLASS_NOTE_TEACHER_URL, { pageNo, pageSize });

// 申请公共教室
export const reqAddPublicClassNote = data =>
    request.post(API.ADD_PUBLICCLASS_NOTE_URL, data);

// 获取公共教室详情
export const reqPublicClassDetail = id =>
    request.get(`${API.GET_PUBLICCLASS_DETAIL_URL}?id=${id}`);

// 删除公共教室预约
export const reqDeletePublicClassNote = id =>
    request.delete(`${API.DELETE_PUBLICCLASS_NOTE_URL}?id=${id}`);

// 审批公共教室预约
export const reqExaminePublicClassNote = ({ id, status }) =>
    request.post(
        `${API.EXAMINE_PUBLICCLASS_NOTE_URL}?id=${id}&status=${status}`
    );
